package com.iwjw.ibatis.util;

import lombok.AllArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author: huangweiwei
 * @email: ihuangweiwei@163.com
 * @created:2016/10/27
 */
@AllArgsConstructor
public enum MySqlType2JavaType {
    BIGINT(Long.class),
    //    TINYINT(Byte.class),
    TINYINT(Integer.class),
    SMALLINT(Short.class),
    MEDIUMINT(Integer.class),
    INTEGER(Integer.class),
    INT(Integer.class),
    FLOAT(Float.class),
    DOUBLE(Double.class),
    DECIMAL(BigDecimal.class),
    NUMERIC(BigDecimal.class),
    CHAR(String.class),
    VARCHAR(String.class),
    TINYBLOB(Byte[].class),
    TINYTEXT(String.class),
    BLOB(Byte[].class),
    TEXT(String.class),
    MEDIUMBLOB(Byte[].class),
    MEDIUMTEXT(String.class),
    LONGBLOB(Byte[].class),
    LONGTEXT(String.class),
    DATE(Date.class),
    TIME(Date.class),
    YEAR(Date.class),
    DATETIME(Date.class),
    TIMESTAMP(Date.class);

    private Class clazz;

    public static Class get(String info) {
        for (MySqlType2JavaType obj : values()) {
            if (obj.name().equals(info)) {
                return obj.clazz;
            }
        }
        return Object.class;
    }
}
